﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>父组件动态传值给子组件</title>
    <style type="text/css">
        * {
            margin: 0;  
            padding: 0;
        }
        input {
            outline: none;
            border: 1px solid #666;
            border-radius:  5px;
            height: 30px;
        }
    
    </style>
</head>
<body>
    <div id="app" style="margin: 50px;">
        <input type="text" v-model="parentMessage">
        <my-component :message="parentMessage"></my-component>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script type="text/javascript">
        var vm = new Vue({
            el: '#app',
            data: {
                parentMessage: "",
            },
            components: {
                'my-component': {
                    props: ['message'],
                    template: '<h3> 传递的值是：{{ message }} </h3>'
                }
            }
        });
    </script>
</body>
</html>
